-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #11654: create new symbol for stdlib patches #11803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d4b9537
to
a33db77
Compare
224a0da
to
6219910
Compare
patch.denot = patch.denot.copySymDenotation(owner = denot.symbol) | ||
patch | ||
else | ||
// change `info` which might contain reference to the patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a TreeTypeMap to map the info instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean for the inline
tree in the annotation? It's quite complex -- we need to create a copy of all local symbols (e.g. for type, term symbols, symbols in the function body, etc.) and rewire them.
For non-inline symbols, we make strong assumptions on symbol.info
, which seems to be simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant for both, but I don't know if TreeTypeMap works on inline defs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a principled way to do this --- a map needs to make assumptions about from
and to
. We will not make fewer assumptions and the code will be complex.
def recurse(patch: Symbol) = patch.is(Module) && scope.lookup(patch.name).exists | ||
|
||
def makeClassSymbol(patch: Symbol, parents: List[Type], selfInfo: TypeOrSymbol) = | ||
newClassSymbol( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we use patch.copy(...)
here? Would that not be shorter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is that info
and symbol
depend on each other, and Symbol.copy
does not support that.
name = patch.name.asTypeName, | ||
flags = patch.flags, | ||
// need to rebuild a fresh ClassInfo | ||
infoFn = cls => ClassInfo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not be shorter to use derivedClassInfo
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does not make much difference, as we change all fields here except parents
. On the other hand, using the constructor makes the implicit assumptions explicit and clear here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, makes sense. Thanks for the explanations!
Fix #11654: create new symbol for stdlib patches
[test_windows_full]